﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE.Web.Betfair.Interface;
using System.Diagnostics.Contracts;

namespace BE.Web.Betfair.EBC
{
    /// <summary>
    /// Extens the Session class
    /// </summary>
    public static class SessionEx
    {
        /// <summary>
        /// Converts the session object to the Global API Request Header
        /// </summary>
        /// <param name="session">The session.</param>
        /// <returns>Global API Request header</returns>
        /// <remarks>Unfortunately, BetFair has defined different Namespaces for its entities, so there are 
        /// two differenz types for Request Header, Global and Sports...</remarks>
        /// <seealso cref="ToExchangeAPIRequestHeader"/>
        public static BE.Web.Betfair.EBC.BetfairGlobal.APIRequestHeader ToGlobaAPIRequestHeader(this Session session)
        {
            #region conditions
            Contract.Requires<ArgumentNullException>(session != null);
            Contract.Ensures(Contract.Result<BE.Web.Betfair.EBC.BetfairGlobal.APIRequestHeader>() != null);
            #endregion

            BE.Web.Betfair.EBC.BetfairGlobal.APIRequestHeader header = new BetfairGlobal.APIRequestHeader();
            header.sessionToken = session.Token;

            return header;
        }


        /// <summary>
        /// Converts the session object to the Global API Request Header
        /// </summary>
        /// <param name="session">The session.</param>
        /// <returns>Global API Request header</returns>
        /// <remarks>Unfortunately, BetFair has defined different Namespaces for its entities, so there are 
        /// two differenz types for Request Header, Global and Sports...</remarks>
        /// <seealso cref="ToGlobaAPIRequestHeader"/>
        public static BE.Web.Betfair.EBC.BetfairExchange.APIRequestHeader ToExchangeAPIRequestHeader(this Session session)
        {
            #region conditions
            Contract.Requires<ArgumentNullException>(session != null);
            Contract.Ensures(Contract.Result<BE.Web.Betfair.EBC.BetfairExchange.APIRequestHeader>() != null);
            #endregion

            BE.Web.Betfair.EBC.BetfairExchange.APIRequestHeader header = new BetfairExchange.APIRequestHeader();
            header.sessionToken = session.Token;

            return header;
        }
    }
}
